package com.rxh.controller;

import com.rxh.pojo.finance.FinanceDrawing;
import com.rxh.service.DrawingService;
import com.rxh.spring.annotation.SystemLogInfo;
import com.rxh.util.ExcelUtils;
import com.rxh.util.UserInfoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author xuzm
 * @date 20180312
 *
 */
@Controller
@RequestMapping("/drawing")
public class DrawingController {
	
    @Autowired
    private DrawingService drawingService;

    
    @RequestMapping("/getDrawingInit")
    @ResponseBody
    public Map<String,Object> getDrawingInit() {
    	
    	return drawingService.getDrawingInit();
       
    }
    
    @RequestMapping("/getDrawingInfo")
    @ResponseBody
    public Map<String,Object> getDrawingInfo(@RequestBody Map<String, Object> paramMap) {
    	
    	return drawingService.getDrawingInfo(paramMap);
       
    }
    
    @RequestMapping("/getDrawingTransferUpdateInit")
    @ResponseBody
    public Map<String,Object> getDrawingTransferUpdateInit(@RequestBody Integer merId) {
    	
    	return drawingService.getDrawingTransferUpdateInit(merId);
       
    }


    /**
     * 
     * @param drawing
     * @return
     */
    @RequestMapping("/update")
    @ResponseBody
    public Map<String, Object> update(@RequestBody FinanceDrawing drawing) {
    	
    	drawing.setTransfer(UserInfoUtils.getName());
    	return drawingService.update(drawing);

    }


    /**
     * 导出excel信息
     *
     * @param searchInfo 查询信息
     */
    @SystemLogInfo(description = "划款信息")
    @RequestMapping(value = "/downloadDrawingInfo", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public void downloadOrderInfo(HttpServletResponse response, @RequestBody Map<String, Object> paramMap) throws IOException {


        List<FinanceDrawing> drawingList = drawingService.getExcelInfo(paramMap);

        ExcelUtils.exportTransferlistToExcel(response, drawingList);



    }



}
